module GoogleAnalyticsTags
	include Radiant::Taggable
	
	desc %{
		Renders the correct javascript for a google analytics account.
		Only does this on a published page.
		
		*Usage*:
		
		<pre><code><r:google_analytics uacct="UA-333333-3" /></code></pre>		
	}
	
	tag "google_analytics" do |tag|
		 raise "'uacct' attribute required" unless tag.attr["uacct"]     
	     	 
		 uacct = tag.attr["uacct"]
		 
		 current = tag.locals.page

			 %{
			   <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
			   <script type="text/javascript">
			   		_uacct = "#{uacct}";
			   		urchinTracker();
			   </script>} unless current.status != "Published"
	end
	
end	